import {Suspense, useEffect} from 'react';
import {useRoutes} from 'react-router-dom';
import {router} from './router';
import {getRouteQueryParam} from './utils';
import {useSystemStore} from './stores';
import LoadingSpinner from './components/LoadingSpinner';

const App = () => {
  const systemStore = useSystemStore();

  useEffect(() => {
    const lang = getRouteQueryParam('lang');
    systemStore.updateState({
      lang: lang || 'zh-cn',
    });
  }, []);
  return (
    <div className="bg-[#0a2044] h-full">
      <Suspense fallback={<LoadingSpinner />}>{useRoutes(router)}</Suspense>
    </div>
  );
};

export default App;
